import * as Y from 'yjs'
import { WebsocketProvider } from 'y-websocket'

// 创建共享文档
export const ydoc = new Y.Doc()

// 创建 WebSocket 连接（需自建服务端）
export const provider = new WebsocketProvider(
  'wss://your-collab-server.com',
  'your-room-name',
  ydoc
)

// 获取用户状态感知对象
export const awareness = provider.awareness

// 生成随机用户颜色
export const generateUserColor = () => 
  `hsl(${Math.floor(Math.random() * 360)}, 70%, 60%)`